package edu.hitsz.supply;

import edu.hitsz.aircraft.AbstractAircraft;
import edu.hitsz.aircraft.HeroAircraft;
import edu.hitsz.bullet.BaseBullet;
import edu.hitsz.application.Game;

public class BombSupply extends AbstractSupply {
    private Game game; // 需要持有Game实例的引用

    public BombSupply(int locationX, int locationY, int speedX, int speedY, Game game) {
        super(locationX, locationY, speedX, speedY);
        this.game = game;
    }

    @Override
    public void effect(HeroAircraft hero) {
        // 清除所有敌机和敌机子弹
        for (AbstractAircraft enemy : game.getEnemyAircrafts()) {
            if (!enemy.notValid()) {
                enemy.vanish();
                // 如果需要加分，应该在Game类中处理，而不是在这里
                 game.increaseScore(10);
            }
        }
        for (BaseBullet bullet : game.getEnemyBullets()) {
            if (!bullet.notValid()) {
                bullet.vanish();
            }
        }
        vanish();
    }
}